home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
ARGONET
/
PD
/
MATHS
/
RLAB
/
RLAB125.ZIP
/
!RLaB
/
help_jr
/
OPERATORS
< prev
next >
Wrap
Text File
|
1994-04-17
|
6KB
|
200 lines
OPERATORS:
DEFINITION: An operator is a symbol(s) that takes operand(s)
as input, and computes a result(s) that is a function of the
operand(s).
We can draw an analogy between operators and functions. The
operands are analogous to a functions arguments, and the
operation result is analogous to the functions return
value(s). Any symbol that does not fit this definition of an
operator is a delimiter. For example: the semi-colon, `;' is
NOT an operator. A user cannot use the semi-colon to generate
a tangible result.
Relational and logical operators are discussed in the
help-file `RELATIONAL' (see `help RELATIONAL').
Valid unary operators (operators that operate on a SINGLE object)
+ unary plus
- unary minus
++ increment
-- decrement
' MATRIX transpose
Note: the increment and decrement operators are NOT exactly
like the C post-increment and post-decrement. RLaB inc/decs
the value of the variable immediately.
Valid binary operators (operate on two objects)
+ addition
.+ addition (el-by-el)
- subtraction
.- subtraction (el-by-el)
* multiplication
.* multiplication (el-by-el)
/ right division (see DIVISION)
./ el-by-el right division (see DIVISION)
\ left division (see DIVISION)
.\ el-by-el left division (see DIVISION)
^ power
.^ el-by-el power
The binary operators are supposed to function like their
MATLAB counterparts. However, there are a few extensions, for
more details - see below.
Following are the rules used for applying the binary operators.
Miscellaneous (but very important) operators.
, concatenation (inside `[' `]' only)
: vector construction
[ ] matrix construction, and MATRIX element reference.
The `:' operator is used to build vectors (a 1xN matrix) with
regular intervals (default interval = 1).
> 1:10
builds the vector `1,2,3,4,5,6,7,8,9,10'
> 1:2:.5
builds the vector `1,1.5,2'
This 1st operand is the vector start value, the 2nd operand is
the vector end value, and the 3rd operand is the vector
increment.
The `;' is the RLaB separator. In some ways it acts as a
vertical append operator, but since it is not accessible to
users as an explicit operator, it is a delimiter.
The `[' and `]' serve a dual function. The first is to serve
as the MATRIX construction operators. Enclose an expression
with `[' and `]' and RLaB will try and make a MATRIX out of
the expression.
The second function of `[' and `]' is to serve as the MATRIX
element reference operators, thus:
> m=[1,2,3;4,5,6;7,8,9]
m =
matrix columns 1 thru 3
1 2 3
4 5 6
7 8 9
builds a matrix, and assigns it to `m'. To reference the
element in the 2nd row, and 2nd column:
> m[2;2]
5
Reference the 2-by-2 sub-matrix formed by extracting the 1st
and 2nd rows, and switching the 2nd and 1st columns.
> m[1,2;2,1]
matrix columns 1 thru 2
2 1
5 4
----------------------------------------------------------------
Element-by-element multiplication (.*): This operator
multiplies two matrices together in a manner deteremined by
the operands dimensions. For C = A.*B:
A (MxN), B (MxN), C (MxN): C is the element-by-element product
of A and B.
A (1x1), B (MxN), C (MxN): C is the product of A and each
element in B.
A (MxN), B (1x1), C (MxN): C is the product of B and each
element in A.
A (0x0), B (MxN), C (0x0): C is the NULL matrix.
A (MxN), B (0x0), C (0x0): C is the NULL matrix.
A (1xN), B (MxN), C (MxN): C is the element-by-element product
of A with each row of B.
A (Mx1), B (MxN), C (MxN): C is the element-by-element product
of A with each column of B.
A (MxN), B (1xN), C (MxN): C is the element-by-element product
of B with each row of A.
A (MxN), B (Mx1), C (MxN): C is the element-by-element product
of B with each column of A.
----------------------------------------------------------------
Element-by-element division (./): This operator divides two
matrices together in a manner deteremined by the operands
dimensions. For C = A./B:
A (MxN), B (MxN), C (MxN): C is the result of
element-by-element division of A and B.
A (1x1), B (MxN), C (MxN): C is the result of division of each
element of B by A.
A (MxN), B (1x1), C (MxN): C is the result of division of each
element of A by B.
A (0x0), B (MxN), C (0x0): C is the NULL matrix.
A (MxN), B (0x0), C (0x0): C is the NULL matrix.
A (1xN), B (MxN), C (MxN): C is the result of
element-by-element division of A with each row of B.
A (Mx1), B (MxN), C (MxN): C is the result of
element-by-element division of A with each column of B.
A (MxN), B (1xN), C (MxN): C is the result of
element-by-element division of each row of A with B.
A (MxN), B (Mx1), C (MxN): C is the result of
element-by-element division of each column of B with A.
----------------------------------------------------------------
Addition is always an element-by-element operation, however
the operand sizes must match. For cases where the operand
sizes do not match (intentionally) the `.+' operator is
supplied. The result is determined by the size of each
operand, for C = A .+ B:
A (MxN), B (MxN), C (MxN): C is the result of
element-by-element addition of A and B.
A (1x1), B (MxN), C (MxN): C is the result of
element-by-element addition of A and each element of B.
A (MxN), B (1x1), C (MxN): C is the result of
element-by-element additiion of each element of A and B.
A (0x0), B (MxN), C (0x0): C is the NULL matrix.
A (MxN), B (0x0), C (0x0): C is the NULL matrix.
A (1xN), B (MxN), C (MxN): C is the result of
element-by-element addition of A and each row of B.
A (Mx1), B (MxN), C (MxN): C is the result of
element-by-element addition of A and each column of B.
A (MxN), B (1xN), C (MxN): C is the result of
element-by-element addition of B and each row of A.
A (MxN), B (Mx1), C (MxN): C is the result of
element-by-element addition of B and each column of A.
----------------------------------------------------------------
Subtractin follows the same dimensional rules as addition.
----------------------------------------------------------------